package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.TakeoutDetailInfo;
import com.pj.wisdomlogistics.mvp.contract.TakeoutDetailContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.TakeoutDetailModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;


public class TakeoutDetailPresenter extends ActivityPresenter<TakeoutDetailModel,TakeoutDetailContract.View> implements TakeoutDetailContract.Presenter{
    public static final String TAG = "TakeoutDetailPresenter";

    @Override
    public void findFoodApplyDetail(int outFoodID) {
        addSubscription(getModel().findFoodApplyDetail(outFoodID), new FilterSubscriber<TakeoutDetailInfo>() {
            @Override
            public void onNext(TakeoutDetailInfo mInfo) {
                getView().showDetailSuccess(mInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

        });
    }

    @Override
    public void foodApplyFinish(int outFoodID) {
        addSubscription(getModel().foodApplyFinish(outFoodID), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().showFinishSuccess();
            }
        });
    }

    @Override
    public void cancelFoodApply(int outFoodID) {
        addSubscription(getModel().cancelFoodApply(outFoodID), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().showError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().showCancelSuccess();
            }
        });
    }
}
